myApp.controller('commoncontroller',
    function($scope, $location, postMealService,$route, $rootScope, $modal) {
            
        $rootScope.showSearchBar = false;
        $rootScope.showWelcomeMessage = false;
        $rootScope.search = {};
        $rootScope.search.mealname = "";
        $rootScope.search.area = "";
        $rootScope.isLoginPage = true;
        
        $rootScope.storeVal = function (key, value){
            sessionStorage.setItem(key, value);
        }
        
        $rootScope.getStoredVal = function (key){
            return sessionStorage.getItem(key);
        }
        $rootScope.user = {};
        $rootScope.user.name = $rootScope.getStoredVal("username");    
        
        $scope.redirectToHome = function() {
            $location.path("/viewMeal");
        }
        
        $rootScope.showAlert = function (msg){
            var modalInstance = $modal.open({
                templateUrl: 'views/html/alertModel.html',
                controller: 'alertMessageCtrl',
                backdrop: 'static',
                resolve: {
                    items: function () {
                        return msg;
                    }
                }
            });
            modalInstance.result.then(function (selectedItem) {
                $scope.selected = selectedItem;
            }, function () {
                });
        };
    });

myApp.controller('alertMessageCtrl', 
    ['$scope', '$modalInstance', 'items',
    function($scope, $modalInstance, items) {
	
        $scope.errorMessage = items;
        $scope.cancel = function () {
            $modalInstance.dismiss('cancel');
        };
    }]);
    